package com.tedu.lingmaagent.utils;

import com.tedu.lingmaagent.domain.Appointment;
import com.tedu.lingmaagent.service.AppointmentService;
import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class AssistantTools {
//    将数据存储到数据库
    @Autowired  // 自动注入服务
    private AppointmentService appointmentService;

    /*
    /*
    *  预约挂号
    * */
    @Tool(name="预约挂号",value="该方法用于数据库插入工作，预约挂号")
    public String appointment(@P("挂号数据封装对象")Appointment  appointment) {
        if(appointment == null){
            return "预约信息为0";
        }
        if(appointmentService.save(appointment)){
            return "预约成功";
        }
        return "预约失败";

    }

    /*
    *  查询当前是否预约挂号，如果已经挂号就不能重复挂号
    * */
    @Tool(name="查询当前人是否预约挂号",value="该方法用于查询当前人是否预约挂号，如果已经挂号就不能重复挂号")
    public String queryAppointment(@P("用户id")String card){
        Appointment appointment = appointmentService.queryAppointment(card);
        if (appointment == null){
            return "当前用户没有预约挂号";

        }
        return "当前用户已经预约挂号了，不能再进行挂号";

    }

    /*
     *  取消预约挂号
     * */
    @Tool(name="取消预约挂号",value="该方法用于取消预约挂号")
    public String cancelAppointment(@P("用户身份证号")String idCard,
                                    @P("预约日期")String date,
                                    @P("预约时间")String time,
                                    @P("预约科室")String department) {
        if (appointmentService.cancelAppointment(idCard, date, time, department)) {
            return "预约取消成功";
        }
        return "预约取消失败，未找到对应的预约信息";
    }

    /*
    * public String removeAppointment(String card){
    *   Appointment appointment = appointmentService.query
    * */

}
